define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order1/index' + location.search,
                    add_url: 'order1/add',
                    edit_url: 'order1/edit',
                    del_url: 'order1/del',
                    multi_url: 'order1/multi',
                    import_url: 'order1/import',
                    table: 'order1',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 's_addr_id', title: __('S_addr_id')},
                        {field: 's2_addr_id', title: __('S2_addr_id')},
                        {field: 'e_addr_id', title: __('E_addr_id')},
                        {field: 'e2_addr_id', title: __('E2_addr_id')},
                        {field: 's_uid', title: __('S_uid')},
                        {field: 'j_uid', title: __('J_uid')},
                        {field: 's_money', title: __('S_money'), operate:'BETWEEN'},
                        {field: 'j_money', title: __('J_money'), operate:'BETWEEN'},
                        {field: 's_load_time', title: __('S_load_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'e_load_time', title: __('E_load_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'money_status', title: __('Money_status'), searchList: {"1":__('Money_status 1'),"2":__('Money_status 2'),"3":__('Money_status 3')}, formatter: Table.api.formatter.status},
                        {field: 's_ps', title: __('S_ps'), operate: 'LIKE'},
                        {field: 'money', title: __('Money'), operate: 'LIKE'},
                        {field: 'load_status', title: __('Load_status'), searchList: {"1":__('Load_status 1'),"2":__('Load_status 2')}, formatter: Table.api.formatter.status},
                        {field: 'lay_status', title: __('Lay_status'), searchList: {"1":__('Lay_status 1'),"2":__('Lay_status 2'),"3":__('Lay_status 3'),"4":__('Lay_status 4')}, formatter: Table.api.formatter.status},
                        {field: 'order', title: __('Order'), operate: 'LIKE'},
                        {field: 'goods_name', title: __('Goods_name'), operate: 'LIKE'},
                        {field: 'long', title: __('Long'), operate:'BETWEEN'},
                        {field: 'wide', title: __('Wide'), operate:'BETWEEN'},
                        {field: 'high', title: __('High'), operate:'BETWEEN'},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"9":__('Status 9')}, formatter: Table.api.formatter.status},
                        {field: 'j_time', title: __('J_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'spay_status', title: __('Spay_status'), searchList: {"1":__('Spay_status 1'),"2":__('Spay_status 2'),"3":__('Spay_status 3')}, formatter: Table.api.formatter.status},
                        {field: 'jpay_status', title: __('Jpay_status'), searchList: {"1":__('Jpay_status 1'),"2":__('Jpay_status 2'),"3":__('Jpay_status 3')}, formatter: Table.api.formatter.status},
                        {field: 'weight', title: __('Weight'), operate:'BETWEEN'},
                        {field: 'km', title: __('Km'), operate:'BETWEEN'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});